﻿$(document).ready(function () {
    var hashpassword = $('.hidPass').val();
    var hashfull = $('.hidHash').val();
    $('.libutton').click(function () {
        var login = $('.loginbox').val().toLowerCase();
        var password = $('.passwordbox').val();
        var secret = $('.hidSecret').val();
        if (login.length <= 0) {
            alert('Please enter a username');
            return false;
        }
        else if (password.length <= 0) {
            alert('Please enter a password');
            return false;
        }
        else if (secret.length <= 0) {
            alert('Error: Unable to generate secret. Please close this browser and try again');
            return false;
        }
        else {
            var hashpass = hex_md5(password).toLowerCase();
            $('.hidPass').val(hashpass);
            var fullprehash = hex_md5(login + hashpass + secret).toLowerCase();
            $('.hidHash').val(fullprehash);
        }

    });
});

